x86/mcheck: allow varying bank counts per CPU
authorJan Beulich <jbeulich@suse.com>
Tue, 25 Jun 2019 15:32:37 +0000 (17:32 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 25 Jun 2019 15:32:37 +0000 (17:32 +0200)
commit560cf418c8455cd8d79ad353f6f9193a2e2554e4
tree5e349b0e53b20184fa840d50df2c82aa2f59de90
parentb41666f2c17f01c437c870389ab713ee62ae3526
x86/mcheck: allow varying bank counts per CPU

Up to now we've been assuming that all CPUs would have the same number
of reporting banks. However, on upcoming AMD CPUs this isn't the case,
and one can observe

(XEN) mce.c:666: Different bank number on cpu <N>

indicating that Machine Check support would not be enabled on the
affected CPUs. Convert the count variable to a per-CPU one, and adjust
code where needed to cope with the values not being the same. In
particular the mcabanks_alloc() invocations during AP bringup need to
now allocate maximum-size bitmaps, because the truly needed size can't
be known until we actually execute on that CPU, yet mcheck_init() gets
called too early to do any allocations itself.

Take the liberty and also
- make mca_cap_init() static,
- replace several __get_cpu_var() uses when a local variable suitable
  for use with per_cpu() appears,
- correct which CPU's cpu_data[] entry x86_mc_msrinject_verify() uses,
- replace a BUG() by panic().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce_amd.c
xen/arch/x86/cpu/mcheck/mce_intel.c
xen/arch/x86/cpu/mcheck/x86_mca.h
xen/arch/x86/hvm/svm/svm.c
xen/include/asm-x86/mce.h